Bhavesh9908/ Building a KD-Tree from Points #11541
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your change:
Added the KD-Tree construction algorithm to the repository.
The 'build_kdtree' function has been implemented to construct a KD-Tree from a list of points, handling different depths and dimensions.
Includes type annotations for better code clarity and maintenance.
The algorithm recursively splits the points based on the median of the axis determined by the depth of the tree.
Added doctests to verify the correctness of the algorithm.
Removed depth from test_build_kdtree: If depth is not used, it's best to remove it. The function build_kdtree should not rely on it unless explicitly designed to do so.
Check for KDNode: Simplified the type checking for KDNode to ensure the KD-Tree is built correctly.
Edge Case Handling: Ensured that edge cases are properly handled with the assumption that an empty KD-Tree should be handled by nearest_neighbour_search.
Ensure that your 'build_kdtree', 'hypercube_points', and 'nearest_neighbour_search' functions are correctly implemented and compatible with the tests.
Checklist: